import { Controller, Get, Inject, Res } from '@nestjs/common';
import { AppService } from './app.service';
import { JwtService } from '@nestjs/jwt';
import {Response} from 'express'

@Controller()
export class AppController {
  @Inject(JwtService)
  private jwtService: JwtService

  constructor(private readonly appService: AppService) {}

  @Get('token')
  // 注入 response 对象之后，默认不会把返回值作为 body 了，需要设置 passthrough 为 true 才可以。
  createToken() {
    const newToken = this.jwtService.sign({
      count: 1000001
    });

    return {
      code: 200,
      data: newToken
    };
  }


  @Get()
  getHello(): string {
    return this.appService.getHello();
  }
}
